function check_city(){		  
	var isStateSelected = $('.niceform input[name="states[]"]:checked').length;
	var isCitySelected = $('.niceform input[name="city[]"]:checked').length;
	if(isStateSelected==0 && isCitySelected==0){
		jQuery("#select_state_city").html(" All Over India");	
	}else{
		 jQuery("#select_state_city").html(" Select States or Cities ");		
	}	
}
function check_region(region,check){		 
	  if(check==false && document.getElementById(region).checked==true){
		  document.getElementById(region).checked=false;	
	  }
	var isStateSelected = $('.niceform input[name="states[]"]:checked').length;
	var isCitySelected = $('.niceform input[name="city[]"]:checked').length;
	if(isStateSelected==0 && isCitySelected==0){
		jQuery("#select_state_city").html(" All Over India");	
	}else{
		 jQuery("#select_state_city").html(" Select States or Cities ");
		
	}	
}

function check_image_select_States(region,states,color){	
	states=states.split(',');			
			for(var i=0;i<states.length;i++){				
				document.getElementById("checkbox_"+states[i]).checked=true;
				if(region=='East'){
					document.getElementById('other').checked=true;						
				}				
			}
	 document.getElementById(region).checked=true;		
}

function check_select_States(t,states,color){
	states=states.split(',');		
		if(t.checked){
			for(var i=0;i<states.length;i++){				
				document.getElementById("checkbox_"+states[i]).checked=true;
				if(t.name=='East'){
					document.getElementById('other').checked=true;						
				}				
			}
			 jQuery("#select_state_city").html(" Select States or Cities ");			
		}else{
			for(var i=0;i<states.length;i++){	
				document.getElementById("checkbox_"+states[i]).checked=false;
				if(t.name=='East'){
					document.getElementById('other').checked=false;						
				}				
			}
		}
	var isStateSelected = $('.niceform input[name="states[]"]:checked').length;
	var isCitySelected = $('.niceform input[name="city[]"]:checked').length;
	if(isStateSelected==0 && isCitySelected==0){
		jQuery("#select_state_city").html(" All Over India");	
	}else{
		 jQuery("#select_state_city").html(" Select States or Cities ");		
	}			
		
}

function tr_on(_tr){
	_tr.style.backgroundColor  = "#E1EEF1";
	
}
function tr_off(_tr){
	_tr.style.backgroundColor  = "#F5F5F5";
}

function go_to_college_profile(form,id,name){ 
	proxy='';
	var frm=document.getElementById(form);
	var place_of_click='organic';
	if(form=='middle_results_form'){
		place_of_click='organic'	
	}else if(form=='top_results_form' || form=='right_results_form') {
		place_of_click='featured'
	}else{
		place_of_click='other'
	}
	
	var course_type=frm.course_type.value;
	increaseClicks(id, course_type, place_of_click);	
	var proxy = 'institute-profile.php?id='+id;	
	var name=name.replace(/^\s+|\s+$/g, '').replace(/\,/g,' ').replace(/\s+/g,'_').replace(/\&/g,'&amp;');	
	proxy=full_path+'/colleges/'+name;	
	frm.id.value=id;	
	frm.name.value=name;	
	window.open(proxy);	
	return false;
}

function go_to_college_profile_placement_cutoff(form,id,name,shortname,pc){
	
	proxy='';
	var frm=document.getElementById(form);
	var place_of_click='organic';
	if(form=='middle_results_form'){
		place_of_click='organic'	
	}else if(form=='top_results_form' || form=='right_results_form') {
		place_of_click='featured'
	}else{
		place_of_click='other'
	}
	var course_type=frm.course_type.value;	
	increaseClicks(id, course_type, place_of_click);	
	var proxy = 'institute-profile.php?id='+id;	
	var name=name.replace(/^\s+|\s+$/g, '').replace(/\,/g,' ').replace(/\s+/g,'_').replace(/\&/g,'&amp;');	
	if(pc=='cutoff'){
		proxy=full_path+'/colleges/'+name+'/'+shortname+'-cutoff';	
	}else{
		proxy=full_path+'/colleges/'+name+'/'+shortname+'-placement';	
	}
	
	frm.id.value=id;	
	frm.name.value=name;	
	window.open(proxy);	
	return false;
}


function checkUpgrade(fieldname){
	with(document.common_upgrade_form)
	{
		document.getElementById('upgrade_field').value=fieldname;
		if(fieldname=='Nearest Railway Station' || fieldname=='Nearest Airport' || fieldname=='College Area'){
			$("#upgrade_field_span").show().html("adding details about the "+fieldname);
		}else if(fieldname=='City Info'){
			$("#upgrade_field_span").show().html("adding details about your city");
		}else if(fieldname=='Full Time Faculty'){
			$("#upgrade_field_span").show().html("adding details about your faculty");
		}else if(fieldname=='More Images'){
			$("#upgrade_field_span").show().html("adding more images");
		}else if(fieldname=='More Documents'){
			$("#upgrade_field_span").show().html("adding more documents");
		}else if(fieldname=='More Videos'){
			$("#upgrade_field_span").show().html("adding more videos");
		}else if(fieldname=='More Events'){
			$("#upgrade_field_span").show().html("adding more events");
		}else if(fieldname=='More Awards'){
			$("#upgrade_field_span").show().html("adding details about your awards and achievements");
		}else if(fieldname=='Additional Links'){
			$("#upgrade_field_span").show().html("adding additional links");
		}else if(fieldname=='Additional Info'){
			$("#upgrade_field_span").show().html("adding additional info");
		}else if(fieldname=='Famous Alumni'){
			$("#upgrade_field_span").show().html("adding details about your famous alumni");
		}else if(fieldname=='Student Requests'){
			$("#upgrade_field_span").show().html("viewing details about student requests");
		}else if(fieldname=='International Collaboration'){
			$("#upgrade_field_span").show().html("adding details about your international collaboration");
		}
	}
}

function send_request_for_upgrade()
{
	var up_contact_email=$("#fancybox-inner .inputsec").val();	
	var up_contact_name=document.getElementById('up_contact_name').value;	
	var up_contact_phone=document.getElementById('up_contact_phone').value;	
	
	
	var upgrade_field=document.getElementById('upgrade_field').value;	
	var main_url=full_path+"/ajax.php?action=send_request_for_upgrade&up_contact_name="+up_contact_name+"&up_contact_email="+up_contact_email+"&up_contact_phone="+up_contact_phone+"&upgrade_field="+upgrade_field;
	if(up_contact_email.value=='' || up_contact_name=='' || up_contact_phone=='')
	{
		$("#fancybox-inner .upgrade_form_text").show().html(" (Please enter required fields.)").css('font-style','italic');
		return false;
	}
	else if(!isValidMail(up_contact_email) && up_contact_email.value!='')
	{		
		$("#fancybox-inner .upgrade_form_text").show().html(" (Please enter a valid email address.)").css('font-style','italic');	
		$("#fancybox-inner .inputsec").focus()
		return false;
	}
	else
	{
		$("#fancybox-inner .upgrade_form_text").hide().html(" (Please wait..)").css({'font-style' : 'italic', 'color' : '#ccc'}).fadeIn();
		$.ajax({type: "GET",url: main_url,async: false,
			
			success:function(response)
			{ 	
						
				if(response.search('request_sent_for_upgrade')!=-1)	
				{						
					$("#fancybox-inner .upgrade_form_text").show().html(" (Request sent successfully.)").css({'font-style' : 'italic', 'color' : 'green'});	
													
					
				}
				else if(response.search('Already Sent')!=-1)	
				{					
					$("#fancybox-inner .upgrade_form_text").show().html(" (Request already sent.)").css({'font-style' : 'italic', 'color' : 'red'});		
				}
				else
				{					
					$("#fancybox-inner .upgrade_form_text").show().html(" (Request could not be sent.)").css({'font-style' : 'italic', 'color' : 'red' });					
					
				}
			}
		  });
	}
}


function checkCreateProfile(){
with(document.create_profile_frm){
		var flag=0;
		if(trim(state.value)=="")
		{
			document.getElementById('state_text').style.display='block';
			flag++;
		}
		else
		{
			$("#state_text").hide();
			
		}
		if(!isNumeric(established.value,"0123456789") || (established.value)=="")
		{
			$("#established_text").show();
			flag++;
		}
		else
		{
			$("#established_text").hide();
			
		}
		if(pv_style.value==""){	
			document.getElementById('pv_style_text').style.display='block';	
			flag++;
		}
		else
		{
			$("#pv_style_text").hide();
			
		}
		if(aff_univ.value==""){	
			document.getElementById('aff_univ_text').style.display='block';	
			flag++;
		}
		else
		{
			$("#aff_univ_text").hide();
			
		}
		if(flag==0){
			document.create_profile_frm.submit();
			return true;	
		}else{
			return false;
		}
	}
	
}
function intOnly(i)
{
	if(i.value.length>0)
	{
		i.value = i.value.replace(/[^\d]+/g, '');
	}
}

function intOnly_college_phone(i)
{
	if(i.value.length>0)
	{
		i.value = i.value.replace(/[^\d]+/g, '');
	}
}

function intOnlyNumeric()
{
	$('.onlyNum').keypress(function(e){
		
		if(window.event)
			keyPressed = e.keyCode; // IE hack
		else
			keyPressed = e.which; // standard method for other
		
		//alert('key '+keyPressed);
		if(keyPressed<48 || keyPressed>58)
		{
		 	if(keyPressed != 8 && keyPressed != 0 && keyPressed != 46)
			{
				if(window.event)
					e.returnValue = false;
				else
				{
					e.preventDefault();
				}
			}
		}
	});

}

//Accept Only Numeric value
	$('.onlyNum').keypress(function(e){
		
		if(window.event)
			keyPressed = e.keyCode; // IE hack
		else
			keyPressed = e.which; // standard method for other
		
		//alert('key '+keyPressed);
		if(keyPressed<48 || keyPressed>58)
		{
		 	if(keyPressed != 8 && keyPressed != 0 && keyPressed != 46)
			{
				if(window.event)
					e.returnValue = false;
				else {
					e.preventDefault();
				}
			}
		 }
	});

function showHideFields(category)
{
	if(category==1 || category==2)
	{
		if(document.getElementById('phd').style.display=='none')		
			document.getElementById('phd').style.display='';
		if(document.getElementById('full_time_regular').style.display=='none')		
			document.getElementById('full_time_regular').style.display='';
	}
	else if(category==3)
	{	
		if(document.getElementById('phd').style.display=='')		
			document.getElementById('phd').style.display='none';
		if(document.getElementById('full_time_regular').style.display=='none')		
			document.getElementById('full_time_regular').style.display='';
	}
	else
	{	
		if(document.getElementById('phd').style.display=='')		
			document.getElementById('phd').style.display='none';
		if(document.getElementById('full_time_regular').style.display=='')		
			document.getElementById('full_time_regular').style.display='none';
	}
}

function checkSeats(control,id)
{	
	
	if(control=='checkbox')
	{		
		if(document.getElementById('checkbox_'+id).checked)
			document.getElementById('textbox_'+id).focus();
	}
	else if(control=='textbox')
	{
		if(document.getElementById('textbox_'+id).value=='')
			document.getElementById('checkbox_'+id).checked=false;		
		else
			document.getElementById('checkbox_'+id).checked=true;		
	}
}
function checkQuota(control,id)
{
	if(control=='checkbox')
	{		
		if(document.getElementById('checkbox_percentage_'+id).checked)
			document.getElementById('textbox_percentage_'+id).focus();
	}
	else if(control=='textbox')
	{
		
		if(document.getElementById('textbox_percentage_'+id).value=='')
			document.getElementById('checkbox_percentage_'+id).checked=false;
		else
			document.getElementById('checkbox_percentage_'+id).checked=true;
	}
}
function checkBoardMarks(control,id)
{
	if(control=='checkbox')
	{		
		if(document.getElementById('checkbox_'+id).checked)
			document.getElementById('textbox_'+id).focus();
	}
	else if(control=='textbox')
	{
		if(document.getElementById('textbox_'+id).value=='')
			document.getElementById('checkbox_'+id).checked=false;
		else
			document.getElementById('checkbox_'+id).checked=true;
	}
}
//declare function
function checkForgotPassword()
{
	with(document.student_login_frm)
	{
		var flag=0;
		if(forget_email.value=="")	
		{
			$('#forget_email_text').html('Please enter your email.');
			document.getElementById('forget_email_text').style.color="red";					
			flag=0;
		}
		else if(!isValidMail(forget_email.value))
		{			
			$('#forget_email_text').html('Please enter a valid email address.');
			document.getElementById('forget_email_text').style.color="red";					
			flag=0;		
		}
		else
		{
			$('#forget_email_text').fadeOut();
			flag++;
		}				
		//alert(flag);return false;
		if(flag==1)		
			document.student_login_frm.submit();
		else
			return false;
	}
}
//declare function
function checkStudentLogin()
{
	with(document.student_login_frm)
	{
		var flag=0;
		if(login_email.value=="")	
		{
			
			$('#login_email_text').html('Please enter your email.');
			document.getElementById('login_email_text').style.color="red";					
			flag=0;
		}
		else if(!isValidMail(login_email.value) && login_email.value!="")
		{			
			$('#login_email_text').html('Please enter your valid email address.');
			document.getElementById('login_email_text').style.color="red";					
			flag=0;		
		}
		else
		{
			$('#login_email_text').fadeOut();
			flag++;
		}
				
		if(password.value=="")
		{
			$('#password_text').hide();
			$('#password_text').html('Please enter your password.');			
			document.getElementById('password_text').style.color="red";					
			$('#password_text').fadeIn();
			flag=0;
		}
		else
		{
			$('#password_text').fadeOut();
			flag++;
		}
				
		//alert(flag);return false;
		if(flag==2)
		
			document.student_login_frm.submit();
		else
			return false;
	}
}

function checkCollegeLogin()
{
	with(document.college_login_frm)
	{
		var flag=0;
		if(login_email.value=="")	
		{
			
			$('#login_email_text').html('Please enter your email.');
			document.getElementById('login_email_text').style.display="block";					
			flag=0;
		}
		
		else
		{
			$('#login_email_text').fadeOut();
			flag++;
		}
				
		if(password.value=="")
		{
			$('#password_text').hide();
			$('#password_text').html('Please enter your password.');			
			document.getElementById('password_text').style.display="block";				
			$('#password_text').fadeIn();
			flag=0;
		}
		else
		{
			$('#password_text').fadeOut();
			flag++;
		}
				
		
		if(flag==2)
		
			document.college_login_frm.submit();
		else
			return false;
	}
}

///Student Registration
function checkStudent_Login()
{
	with(document.student_frm)
	{
		var flag=0;
		
		if(trim(name.value)=="")
		{
			document.getElementById('name_text').style.display='block';
			flag++;
		}
		else
		{
			$("#name_text").hide();
			
		}
		
		if(!isValidMail(email.value))
		{
			$("#email_text").show();
			flag++;
		}
		else
		{
			$("#email_text").hide();
			
		}
		if(password.value=="")
		{
			$("#password_text").show();
			flag++;
		}
		else
		{
			$("#password_text").hide();
			
		}
			
		
		if(agree.checked==false){
				$("#agree_msg").show();
				flag++;
				
		}
		else
		{
			$("#agree_msg").hide();
			
		}
		if(flag==0){
			document.student_frm.submit();
			return true;	
		}else{
			return false;
		}
	}
}



///Student Login Box
function check_Student_Login()
{
	
	
	with(document.student_login_frm)
	{	
		
		var flag=0;			
		
		if(!isValidMail(student_email.value))
		{
			$("#student_email_text").show();
			flag++;
		}else{
			$("#student_email_text").hide();
			
		}
		if(student_password.value=="")
		{
			$("#student_password_text").show();
			flag++;
		}else{
			$("student_password_text").hide();			
		}		
		if(document.getElementById('is_send_profile').value==1){
		///Student Login Box	
		var main_url=full_path+"/ajax.php?action=student_login&email="+document.getElementById('student_email').value+"&password="+document.getElementById('student_password').value+"&remember_student="+document.getElementById('remember_student').value+"&institute_id="+document.getElementById('login_institute_id').value+"&course_type="+document.getElementById('login_course_type').value;		
		}else{
			var main_url=full_path+"/ajax.php?action=student_login&email="+document.getElementById('student_email').value+"&password="+document.getElementById('student_password').value+"&remember_student="+document.getElementById('remember_student').value+"&institute_id="+document.getElementById('login_institute_id').value;	
		}
		///Student Login Box
		if(flag==0){
				$.ajax({type: "GET",url: main_url,async: false,
			success:function(response){	
				if(response.search('Login Successful')!=-1)	{
					
	if(document.getElementById('is_send_profile').value==1){						
				window.open(full_path+'/send-profile.php?institute_id='+document.getElementById('login_institute_id').value+'&course_type='+document.getElementById('login_course_type').value);					
	}else if(document.student_login_frm.is_shortlist.value==1){
		addToShortList2(document.getElementById('login_institute_id').value,document.getElementById('login_course_type').value);
											
	}
	}else if(response.search('Password Mismatch')!=-1)	{
					$('#student_password_text').show().html('Incorrect Password');
					flag++;
				}else if(response.search('Account Not Active')!=-1)	{
					$('#student_email_text').show().html('Your account is not active');
					flag++;
				}else if(response.search('Email does not exist')!=-1)	{					
					$('#student_email_text').show().html('This email address does not exist');					
					flag++;
				}
				
				
			}
		});
			//document.student_login_frm.submit();
			//return true;	
		
		}
		if(flag!=0){
			return false;
		}
	}
}




function checkStudentUpdateProfile()
{
	with(document.student_frm)
	{
		var flag=0;
		if(!isValidMail(email.value))
		{			
			$('#email_text').html('Please enter your valid email address.');
			document.getElementById('email_text').style.color="red";					
			flag=0;		
		}
		else
		{
			$('#email_text').hide();
			flag++;
		}
		if(name.value=="")
		{
			$('#name_text').hide();
			$('#name_text').html('Name can not be blank.');			
			document.getElementById('name_text').style.color="red";					
			$('#name_text').fadeIn();
			flag=0;
		}
		else
		{
			$('#name_text').fadeOut();
			flag++;
		}		
		if(!isString(name.value))
		{
			$('#name_text').hide();
			$('#name_text').html('Please enter a valid name.');			
			document.getElementById('name_text').style.color="red";					
			$('#name_text').fadeIn();
			flag=0;
		}
		else
		{
			$('#name_text').fadeOut();
			flag++;
		}		
		if(old_password.value!="")
		{
			if(new_password.value=="")
			{
				$('#new_password_text').hide();
				$('#new_password_text').html('Please enter your password.');			
				document.getElementById('new_password_text').style.color="red";					
				$('#new_password_text').fadeIn();
				flag=0;
			}
			else
			{
				$('#new_password_text').fadeOut();
				flag++;
			}			
			if(new_password.value!=confirm_password.value)
			{
				$('#confirm_password_text').hide();
				$('#confirm_password_text').html('Password does not match.');			
				document.getElementById('confirm_password_text').style.color="red";					
				$('#confirm_password_text').fadeIn();
				flag=0;
			}
			else
			{
				$('#confirm_password_text').fadeOut();
				flag++;
			}
		}		
		if(isNaN(a_code.value) || isNaN(b_code.value) || isNaN(c_code.value))
		{
			$('#phone_text').hide().html('Please enter a valid phone number.').css('color', 'red').fadeIn();
			flag=0;
		}
		else
		{
			$('#phone_text').fadeOut();
			flag++;
		}		
		if(!isNumeric(mobile.value,"0123456789"))
		{
			$('#mobile_text').hide();
			$('#mobile_text').html('Please enter a valid mobile number.');			
			document.getElementById('mobile_text').style.color="red";					
			$('#mobile_text').fadeIn();
			flag=0;
		}
		else
		{
			$('#mobile_text').fadeOut();
			flag++;
		}
		if(mobile.value=="")
		{			
			$('#mobile_text').hide();
			$('#mobile_text').html('Mobile not can not be blank.');			
			document.getElementById('mobile_text').style.color="red";					
			$('#mobile_text').fadeIn();
			flag=0;
		}
		else
		{
			$('#mobile_text').fadeOut();
			flag++;
		}
		if(d.value=="" || m.value=="" || y.value=="")
		{
			$('#dob_text').hide();
			$('#dob_text').html('Please select your date of birth.');			
			document.getElementById('dob_text').style.color="red";					
			$('#dob_text').fadeIn();
			flag=0;
		}
		else
		{
			$('#dob_text').fadeOut();
			flag++;
		}
		if(school_name.value=="")
		{
			$('#school_name_text').hide();
			$('#school_name_text').html('Enter the name of your school.');			
			document.getElementById('school_name_text').style.color="red";					
			$('#school_name_text').fadeIn();
			flag=0;
		}
		else if(!isString(name.value))
		{
			$('#school_name_text').hide();
			$('#school_name_text').html('Enter a valid name of your school.');			
			document.getElementById('school_name_text').style.color="red";					
			$('#school_name_text').fadeIn();
			flag=0;
		}
		else
		{
			$('#school_name_text').fadeOut();
			flag++;
		}
		if(state.value=="")
		{
			$('#state_text').hide();
			$('#state_text').html('Please select state of your school.');			
			document.getElementById('state_text').style.color="red";					
			$('#state_text').fadeIn();
			flag=0;
		}
		else
		{
			$('#state_text').fadeOut();
			flag++;
		}
		if(tenth_board.value=="")
		{
			$('#tenth_board_text').hide();
			$('#tenth_board_text').html('Please select your 10th board.');			
			document.getElementById('tenth_board_text').style.color="red";					
			$('#tenth_board_text').fadeIn();
			flag=0;
		}
		else
		{
			$('#tenth_board_text').fadeOut();
			flag++;
		}		
		if(tenth_marks.value=="")
		{
			$('#tenth_marks_text').hide();
			$('#tenth_marks_text').html('Please enter your Grade or Marks (%) in 10th Boards.');			
			document.getElementById('tenth_marks_text').style.color="red";					
			$('#tenth_marks_text').fadeIn();
			flag=0;
		}
		else
		{
			$('#tenth_marks_text').fadeOut();
			flag++;
		}
		if(twelthth_board.value=="")
		{
			$('#twelthth_board_text').hide();
			$('#twelthth_board_text').html('Please select your 10th board.');			
			document.getElementById('twelthth_board_text').style.color="red";					
			$('#twelthth_board_text').fadeIn();
			flag=0;
		}
		else
		{
			$('#twelthth_board_text').fadeOut();
			flag++;
		}
		if(twelthth_board_marks.value=="")
		{
			$('#twelthth_board_marks_text').hide();
			$('#twelthth_board_marks_text').html('Please enter your marks obtained in 12th board.');			
			document.getElementById('twelthth_board_marks_text').style.color="red";					
			$('#twelthth_board_marks_text').fadeIn();
			flag=0;
		}
		else
		{
			$('#twelthth_board_marks_text').fadeOut();
			flag++;
		}
		if(description.value=="")
		{
			$('#description_text').hide();
			$('#description_text').html('200 characters or less.');			
			document.getElementById('description_text').style.color="red";					
			$('#description_text').fadeIn();
			flag=0;
		}
		else
		{
			$('#description_text').fadeOut();
			flag++;
		}
		//alert(flag);return false;				
		if(flag==16 || flag==14)		
			document.student_frm.submit();
		else
			return false;
	}
}


function checkStudentRegistration()
{
	with(document.student_frm)
	{
		var flag=0;
		if(email.value=="")	
		{
			$('#email_text').html('Please give your complete email ID i.e. abc@xyz.com');
			document.getElementById('email_text').style.color="red";
			flag=0;
		}
		else if(!isValidMail(email.value))
		{			
			$('#email_text').html('Please enter your valid email address.');
			document.getElementById('email_text').style.color="red";					
			flag=0;		
		}
		else
		{
			$.ajax({type: "GET",url: "ajax.php",data: "action=checkemail&email="+email.value,async: false,
				success:function(response)
				{ 
					if(response=='yes')
					{	
						$("#email_text").html("Email id already exists.").css("color","red").show();									
						flag=0;
					}
					else
					{
						$('#email_text').hide();
						flag++;
					}
				}
			  });
		}
		if(trim(name.value)=="")
		{
			$('#name_text').hide();
			$('#name_text').html('Name can not be blank.');			
			document.getElementById('name_text').style.color="red";					
			$('#name_text').fadeIn();
			flag=0;
		}
		else
		{
			$('#name_text').fadeOut();
			flag++;
		}			
		if(password.value=="")
		{
			$('#password_text').hide();
			$('#password_text').html('Please enter your password.');			
			document.getElementById('password_text').style.color="red";					
			$('#password_text').fadeIn();
			flag=0;
		}
		else
		{
			$('#password_text').fadeOut();
			flag++;
		}
		if(password.value.length<6)
		{
			$('#password_text').hide();
			$('#password_text').html('Password must be atleast 6 characters long.');			
			document.getElementById('password_text').style.color="red";					
			$('#password_text').fadeIn();
			flag=0;
		}
		else
		{
			$('#password_text').fadeOut();
			flag++;
		}
		if(confirm_password.value!=password.value)
		{
			$('#confirm_password_text').hide();
			$('#confirm_password_text').html('Password does not match.');			
			document.getElementById('confirm_password_text').style.color="red";					
			$('#confirm_password_text').fadeIn();
			flag=0;
		}
		else
		{
			$('#confirm_password_text').fadeOut();
			flag++;
		}
						
		if(trim(mobile.value)=="")
		{
			$('#mobile_text').hide();
			$('#mobile_text').html('Please enter a valid mobile number.');			
			document.getElementById('mobile_text').style.color="red";					
			$('#mobile_text').fadeIn();
			flag=0;
		}
		else
		{
			$('#mobile_text').fadeOut();
			flag++;
		}		
		if(d.value=="" || m.value=="" || y.value=="")
		{
			$('#dob_text').hide();
			$('#dob_text').html('Please select your date of birth.');			
			document.getElementById('dob_text').style.color="red";					
			$('#dob_text').fadeIn();
			flag=0;
		}
		else
		{
			$('#dob_text').fadeOut();
			flag++;
		}
		if(trim(school_name.value)=="")
		{
			$('#school_name_text').hide();
			$('#school_name_text').html('Please enter the name of your school.');			
			document.getElementById('school_name_text').style.color="red";					
			$('#school_name_text').fadeIn();
			flag=0;
		}		
		else
		{
			$('#school_name_text').fadeOut();
			flag++;
		}
		if(state.value=="")
		{
			$('#state_text').hide();
			$('#state_text').html('Please select state of your school.');			
			document.getElementById('state_text').style.color="red";					
			$('#state_text').fadeIn();
			flag=0;
		}
		else
		{
			$('#state_text').fadeOut();
			flag++;
		}
		if(tenth_board.value=="")
		{
			$('#tenth_board_text').hide();
			$('#tenth_board_text').html('Please select your 10th board.');			
			document.getElementById('tenth_board_text').style.color="red";					
			$('#tenth_board_text').fadeIn();
			flag=0;
		}
		else
		{
			$('#tenth_board_text').fadeOut();
			flag++;
		}		
		/*if(!isNumeric(tenth_marks.value,"0123456789"))
		{
			$('#tenth_marks_text').hide();
			$('#tenth_marks_text').html('Please enter your marks obtained in 10th board.');			
			document.getElementById('tenth_marks_text').style.color="red";					
			$('#tenth_marks_text').fadeIn();
			flag=0;
		}
		else
		{
			$('#tenth_marks_text').fadeOut();
			flag++;
		}*/
		if(trim(tenth_marks.value)=="")
		{
			$('#tenth_marks_text').hide();
			$('#tenth_marks_text').html('Please enter your Grade or Marks (%) in 10th Boards.');			
			document.getElementById('tenth_marks_text').style.color="red";					
			$('#tenth_marks_text').fadeIn();
			flag=0;
		}
		else
		{
			$('#tenth_marks_text').fadeOut();
			flag++;
		}
		
		/*if(twelthth_board.value=="")
		{
			$('#twelthth_board_text').hide();
			$('#twelthth_board_text').html('Please select your 10th board.');			
			document.getElementById('twelthth_board_text').style.color="red";					
			$('#twelthth_board_text').fadeIn();
			flag=0;
		}
		else
		{
			$('#twelthth_board_text').fadeOut();
			flag++;
		}
		
		
		if(trim(twelthth_board_marks.value)=="")
		{
			$('#twelthth_board_marks_text').hide();
			$('#twelthth_board_marks_text').html('Please enter your marks obtained in 12th board.');			
			document.getElementById('twelthth_board_marks_text').style.color="red";					
			$('#twelthth_board_marks_text').fadeIn();
			flag=0;
		}
		else
		{
			$('#twelthth_board_marks_text').fadeOut();
			flag++;
		}
		
		if(trim(description.value)=="")
		{
			$('#description_text').hide();
			$('#description_text').html('200 characters or less.');			
			document.getElementById('description_text').style.color="red";					
			$('#description_text').fadeIn();
			flag=0;
		}
		else
		{
			$('#description_text').fadeOut();
			flag++;
		}
		*/
				
		//alert(flag);return false;
		
		if(flag==11){				
			if(agree.checked==false){
				$("#agree_msg").hide().html("Please read and accept the Terms and Conditions to register.").css("color","red").fadeIn();
				return false;
			}
			else{
				
				document.student_frm.submit();
			}
		}
		else
			return false;
	}
}


function checkStudentUpdateProfile()
{
	with(document.student_frm)
	{
		var flag=0;		
		if(!isValidMail(email.value))
		{			
			$('#email_text').html('Please enter your valid email address.');
			document.getElementById('email_text').style.color="red";					
			flag=0;		
		}
		else
		{
			$('#email_text').hide();
			flag++;
		}
		if(trim(name.value)=="")
		{
			$('#name_text').hide();
			$('#name_text').html('Name can not be blank.');			
			document.getElementById('name_text').style.color="red";					
			$('#name_text').fadeIn();
			flag=0;
		}
		else
		{
			$('#name_text').fadeOut();
			flag++;
		}			
		if(password.value=="")
		{
			$('#password_text').hide();
			$('#password_text').html('Please enter your password.');			
			document.getElementById('password_text').style.color="red";					
			$('#password_text').fadeIn();
			flag=0;
		}
		else
		{
			$('#password_text').fadeOut();
			flag++;
		}
		if(password.value.length<6)
		{
			$('#password_text').hide();
			$('#password_text').html('Password must be atleast 6 characters long.');			
			document.getElementById('password_text').style.color="red";					
			$('#password_text').fadeIn();
			flag=0;
		}
		else
		{
			$('#password_text').fadeOut();
			flag++;
		}
		if(confirm_password.value!=password.value)
		{
			$('#confirm_password_text').hide();
			$('#confirm_password_text').html('Password does not match.');			
			document.getElementById('confirm_password_text').style.color="red";					
			$('#confirm_password_text').fadeIn();
			flag=0;
		}
		else
		{
			$('#confirm_password_text').fadeOut();
			flag++;
		}			
		if(trim(mobile.value)=="")
		{
			$('#mobile_text').hide();
			$('#mobile_text').html('Please enter a valid mobile number.');			
			document.getElementById('mobile_text').style.color="red";					
			$('#mobile_text').fadeIn();
			flag=0;
		}
		else
		{
			$('#mobile_text').fadeOut();
			flag++;
		}		
		if(d.value=="" || m.value=="" || y.value=="")
		{
			$('#dob_text').hide();
			$('#dob_text').html('Please select your date of birth.');			
			document.getElementById('dob_text').style.color="red";					
			$('#dob_text').fadeIn();
			flag=0;
		}
		else
		{
			$('#dob_text').fadeOut();
			flag++;
		}
		if(trim(school_name.value)=="")
		{
			$('#school_name_text').hide();
			$('#school_name_text').html('Please enter the name of your school.');			
			document.getElementById('school_name_text').style.color="red";					
			$('#school_name_text').fadeIn();
			flag=0;;
		}
		else
		{
			$('#school_name_text').fadeOut();
			flag++;
		}		
		if(state.value=="")
		{
			$('#state_text').hide();
			$('#state_text').html('Please select state of your school.');			
			document.getElementById('state_text').style.color="red";					
			$('#state_text').fadeIn();
			flag=0;
		}
		else
		{
			$('#state_text').fadeOut();
			flag++;
		}
		if(tenth_board.value=="")
		{
			$('#tenth_board_text').hide();
			$('#tenth_board_text').html('Please select your 10th board.');			
			document.getElementById('tenth_board_text').style.color="red";					
			$('#tenth_board_text').fadeIn();
			flag=0;
		}
		else
		{
			$('#tenth_board_text').fadeOut();
			flag++;
		}		
		if(trim(tenth_marks.value)=="")
		{
			$('#tenth_marks_text').hide();
			$('#tenth_marks_text').html('Please enter your Grade or Marks (%) in 10th Boards.');			
			document.getElementById('tenth_marks_text').style.color="red";					
			$('#tenth_marks_text').fadeIn();
			flag=0;
		}
		else
		{
			$('#tenth_marks_text').fadeOut();
			flag++;
		}
		
		/*if(twelthth_board.value=="")
		{
			$('#twelthth_board_text').hide();
			$('#twelthth_board_text').html('Please select your 10th board.');			
			document.getElementById('twelthth_board_text').style.color="red";					
			$('#twelthth_board_text').fadeIn();
			flag=0;
		}
		else
		{
			$('#twelthth_board_text').fadeOut();
			flag++;
		}
		
		
		if(trim(twelthth_board_marks.value)=="")
		{
			$('#twelthth_board_marks_text').hide();
			$('#twelthth_board_marks_text').html('Please enter your marks obtained in 12th board.');			
			document.getElementById('twelthth_board_marks_text').style.color="red";					
			$('#twelthth_board_marks_text').fadeIn();
			flag=0;
		}
		else
		{
			$('#twelthth_board_marks_text').fadeOut();
			flag++;
		}
		if(trim(description.value)=="")
		{
			$('#description_text').hide();
			$('#description_text').html('200 characters or less.');			
			document.getElementById('description_text').style.color="red";					
			$('#description_text').fadeIn();
			flag=0;
		}
		else
		{
			$('#description_text').fadeOut();
			flag++;
		}	
		*/	
		//alert($("#student_frm").serialize());return false;
		
		if(flag==11)		
			document.student_frm.submit();
		else
			return false;
	}
}
function isValidMail(email)
{
	var rule = /^([A-Za-z0-9_\-\.])+\@([A-Za-z0-9_\-\.])+\.([A-Za-z]{2,4})$/;	
	if(!rule.test(email)) 
		return false;
	else
		return true;			
}
function checkOnblur(control,message)
{
	if(document.getElementById(control.name+"_text"))
	document.getElementById(control.name+"_text").style.color='red';		
	if(control.name=='email')
	{
		if(!isValidMail(control.value))
		{			
			jQuery("#"+control.name+"_text").html(message);
			jQuery("#"+control.name+"_text").fadeIn(500);			
		}
		else
		{
			/*$.ajax({type: "GET",url: "ajax.php",data: "action=checkemail&email="+control.value,async: false,
				success:function(response)
				{ 
					if(response=='yes')
					{						
						jQuery("#"+control.name+"_text").html("Email id already exists.");
						jQuery("#"+control.name+"_text").fadeIn(500);
					}
					else
					{					
						jQuery("#"+control.name+"_text").fadeOut(500);					
					}
				}
			  });*/
			  jQuery("#"+control.name+"_text").fadeOut(500);						
		}
	}
	else if(control.name=='name' || control.name=='contact_name' || control.name=='institute_name')
	{		
		if(!isString(control.value))
		{				
			jQuery("#"+control.name+"_text").html(message);
			jQuery("#"+control.name+"_text").fadeIn(500);			
		}
		else
		{		
			jQuery("#"+control.name+"_text").fadeOut(500);		
		}
	}
	else if(control.name=='forget_email')
	{		
		if(!isValidMail(control.value))
		{				
			jQuery("#"+control.name+"_text").html(message);
			jQuery("#"+control.name+"_text").fadeIn(500);			
		}
		else
		{		
			jQuery("#"+control.name+"_text").fadeOut(500);		
		}
	}
	else if(control.name=='login_email')
	{		
		if(!isValidMail(control.value))
		{				
			jQuery("#"+control.name+"_text").html(message);
			jQuery("#"+control.name+"_text").fadeIn(500);			
		}
		else
		{		
			jQuery("#"+control.name+"_text").fadeOut(500);		
		}
	}
	else if(control.name=='a_code' || control.name=='b_code' || control.name=='c_code')
	{		
		if(isNaN(control.value))
		{					
			$('#phone_text').hide().html('Please enter a valid phone number.').css('color', 'red').fadeIn();
		}
		else
		{
			$('#phone_text').fadeOut();
		}
	}
	else if(control.name=='mobile')
	{
		if(!isNumeric(control.value,"0123456789") || control.value=="")
		{				
			jQuery("#"+control.name+"_text").html(message);
			jQuery("#"+control.name+"_text").fadeIn(500);			
		}
		else
		{		
			jQuery("#"+control.name+"_text").fadeOut(500);		
		}
	}
	else if(control.name=='phone')
	{
		if(!isNumeric(control.value,"-0123456789") || control.value=="")
		{				
			jQuery("#"+control.name+"_text").html(message);
			jQuery("#"+control.name+"_text").fadeIn(500);			
		}
		else
		{		
			jQuery("#"+control.name+"_text").fadeOut(500);		
		}
	}
	else if(control.name=='established')
	{
		if(!isNumeric(control.value,"0123456789") || control.value=="")
		{				
			jQuery("#"+control.name+"_text").html(message);
			jQuery("#"+control.name+"_text").fadeIn(500);			
		}
		else
		{		
			jQuery("#"+control.name+"_text").fadeOut(500);		
		}
	}
	/*else if(control.name=='tenth_marks')
	{
		if(!isNumeric(control.value,"0123456789%") || control.value=="")
		{				
			jQuery("#"+control.name+"_text").html(message);
			jQuery("#"+control.name+"_text").fadeIn(500);			
		}
		else
		{		
			jQuery("#"+control.name+"_text").fadeOut(500);		
		}
	}*/
	else if(control.name=='twelthth_board_marks')
	{
		if(!isNumeric(control.value,"0123456789%") || control.value=="")
		{				
			jQuery("#"+control.name+"_text").html(message);
			jQuery("#"+control.name+"_text").fadeIn(500);			
		}
		else
		{		
			jQuery("#"+control.name+"_text").fadeOut(500);		
		}
	}
	else if(control.name=='confirm_password')
	{
		if(control.value!=jQuery("#password").val())
		{				
			jQuery("#"+control.name+"_text").html(message);
			jQuery("#"+control.name+"_text").fadeIn(500);				
		}
		else
		{		
			jQuery("#"+control.name+"_text").fadeOut(500);						
		}
	}
	else if(control.name == 'school_name')
	{
		if(!isString(control.value))
		{
			jQuery("#"+control.name+"_text").hide().html('Enter a valid name of your school.').css('color','red').fadeIn();
		}
		else
		{		
			jQuery("#"+control.name+"_text").fadeOut(500);						
		}
	}
	else if(trim(control.value)=='')
	{		
		jQuery("#"+control.name+"_text").html(message);
		jQuery("#"+control.name+"_text").fadeIn(500);			
	}
	else
	{
		jQuery("#"+control.name+"_text").fadeOut(500);					
	}
}
function trim(s)
{
	while (s.substring(0,1) == ' ')
	{
		s = s.substring(1,s.length);
	}
	while (s.substring(s.length-1,s.length) == ' ')
	{
		s = s.substring(0,s.length-1);
	}
	return s;
}
function isNumeric(str,allowed)
{
	var strValidChars = allowed;
	var strChar;
	var blnResult = true;
	for (i = 0; i < str.length && blnResult == true; i++)
	{
		strChar = str.charAt(i);
		if(strValidChars.indexOf(strChar) == -1)		
			blnResult = false;		
	}
	return blnResult;
}
function countWords(t)
{
	
	if(t.value.length>199)
	{	
		document.student_frm.description.value=document.student_frm.description.value.substr(0,199);
	}
	else
	{
		$('#description_text').css('color','red').html((200-document.student_frm.description.value.length)+' characters or less.');
	}	
}

function countWords_description(t,form_name)
{
	var frm=document.getElementById(form_name);	
	if(t.value.length>500)
	{	
		frm.description.value=frm.description.value.substr(0,500);
	}
	else
	{
		$('#description_text').css('color','#D85A5E').html((500-frm.description.value.length)+' characters or less.');
	}	
}
function countWords_feedback(t,form_name)
{
	var frm=document.getElementById(form_name);	
	
	if(t.value.length>500)
	{	
		frm.feedback_description.value=frm.feedback_description.value.substr(0,500);
	}
	else
	{
		$('#feedback_description_text').css('color','#D85A5E').html((500-frm.feedback_description.value.length)+' characters or less.');
		$("#feedback_description_text").show();
	}	
}


function chkfeedbackFrm(page){
	
	with(document.feedbackFrm)
	{
		var flag=0;
		
		if(trim(feedback_description.value)=="")
		{
			$("#feedback_description_text").html(" Please enter feedback");
			$("#feedback_description_text").show();
			flag++;
			return false;	
		}
		
		if(trim(feedback_name.value)=="")
		{
			$("#feedback_name_text").html(" Please enter name");
			$("#feedback_name_text").show();
			flag++;
			return false;	
		}else{
			$("#feedback_name_text").html('');
		}
		if(!isValidMail(feedback_email.value))
		{
			$("#feedback_email_text").html(" Please enter a valid email address");
			$("#feedback_email_text").show();
			flag++;
			return false;	
		}else{
			$("#feedback_email_text").html('');
		}
		if(trim(feedback_name.value)!="" && !isNumeric(feedback_phone.value,"0123456789")){			
		
		$("#feedback_phone_text").html(" Please enter numbers only");
		$("#feedback_phone_text").show();
			flag++;
			return false;			
		}else{
			$("#feedback_phone_text").html('');
		}
		if(flag==0){
			
			var main_url=full_path+"/ajax.php?action=sendFeedback&description="+document.getElementById('feedback_description').value+"&email="+document.getElementById('feedback_email').value+"&name="+document.getElementById('feedback_name').value+"&phone="+document.getElementById('feedback_phone').value+"&page="+page;		
				$.ajax({type: "GET",url: main_url,async: false,
			success:function(response){	
				if(response.search('feedback_sent')!=-1)	{
					
					
					$("#success_feedback").html("Thanks for sending your feedback.");					
					$("#success_feedback").show();
					if(page=='f'){
						$("#feedbackFrm").hide();
						$("#h3_feedback").hide();					
					}
										
				}else {
					alert('Feedback not submitted');
					flag++;
					
				}				
			}
		});
		
		return false;	
		}else{
			return false;	
		}
			
		
	}
}



function isString(str)
{	var regexLetter = /[0-9]/;
	if(regexLetter.test(str) || str == '')
		return false;
	else
		return true;		
}
function checkInstituteStepTwo()
{		
	with(document.institute_frm)
	{
		var checkCourseSeat=0;
		var courses=document.getElementsByName('courses[]');
		var seats=document.getElementsByName('seats[]');
		for(var i=0;i<courses.length;i++){
			if(courses[i].checked && trim(seats[i].value)!="")
				checkCourseSeat++;
		}
		var checkReservation=0;
		var reservation=document.getElementsByName('reservation[]');
		var percentage=document.getElementsByName('percentage[]');
		for(var i=0;i<reservation.length;i++){
			if(reservation[i].checked && trim(percentage[i].value)!="")
				checkReservation++;
		}
		
		var checkEligibility=0;
		var eligibility=document.eligibility;		
		for(var i=0;i<eligibility.options.length;i++){
			if(eligibility.options[i].selected)
				checkEligibility++;
		}	
		
		var flag=0;
		
		/*if(checkCourseSeat==0)
		{
			$("#courses_seat_text").hide().html("Please select courses and enter their respective seats.").css("color","red").fadeIn();
			flag=0;
		}
		else
		{
			$("#courses_seat_text").hide();
			flag++;
		}*/
		if(trim(principal.value)=="")
		{
			$("#principal_text").hide().html("Please enter the name of principal.").css("color","red").fadeIn();
			flag=0;
		}
		else
		{
			$("#principal_text").hide();
			flag++;
		}
		/*if(checkReservation==0)
		{
			$("#reservation_text").hide().html("Please select reservation and enter their percentage.").css("color","red").fadeIn();
			flag=0;
		}
		else
		{
			$("#reservation_text").hide();
			flag++;
		}*/
		if(checkEligibility==0)
		{
			$("#criteria_text").hide().html("Please select eligibility.").css("color","red").fadeIn();
			flag=0;
		}
		else
		{
			$("#criteria_text").hide();
			flag++;
		}
		if(trim(institute_name.value)=="")
		{
			$("#institute_name_text").hide().html("Please enter institute name.").css("color","red").fadeIn();
			flag=0;
		}
		else
		{
			$("#institute_name_text").hide();
			flag++;
		}
		if(trim(contact_name.value)=="")
		{
			$("#contact_name_text").hide().html("Please enter contact name.").css("color","red").fadeIn();
			flag=0;
		}
		else
		{
			$("#contact_name_text").hide();
			flag++;
		}
		if(!isValidMail(email.value))
		{
			$("#email_text").hide().html("Please enter a valid email address.").css("color","red").fadeIn();
			flag=0;
		}
		else
		{
			$("#email_text").hide();
			flag++;
		}
		if(password.value=="")
		{
			$("#password_text").hide().html("Please enter your password.").css("color","red").fadeIn();
			flag=0;
		}
		else
		{
			$("#password_text").hide();
			flag++;
		}
		if(confirm_password.value=="")
		{
			$("#confirm_password_text").hide().html("Please confirm your password.").css("color","red").fadeIn();
			flag=0;
		}
		else
		{
			$("#confirm_password_text").hide();
			flag++;
		}
		if(confirm_password.value!=password.value)
		{
			$("#confirm_password_text").hide().html("Your passwords do not match.").css("color","red").fadeIn();
			flag=0;
		}
		else
		{
			$("#confirm_password_text").hide();
			flag++;
		}
		if(trim(address.value)=="")
		{
			$("#address_text").hide().html("Please enter address.").css("color","red").fadeIn();
			flag=0;
		}
		else
		{
			$("#address_text").hide();
			flag++;
		}
		/*if(trim(city.value)=="")
		{
			$("#city_text").hide().html("Please enter city.").css("color","red").fadeIn();
			flag=0;
		}
		else
		{
			$("#city_text").hide();
			flag++;
		}*/
		if(state.selectedIndex==0)
		{
			$("#state_text").hide().html("Please select state.").css("color","red").fadeIn();
			flag=0;
		}
		else
		{
			$("#state_text").hide();
			flag++;
		}		
		if(!isNumeric(phone.value,"-0123456789") || trim(phone.value)=="")
		{
			$("#phone_text").hide().html("Please enter a valid phone number.").css("color","red").fadeIn();
			flag=0;
		}
		else
		{
			$('#phone_text').fadeOut();
			flag++;
		}
		if(!isNumeric(established.value,"0123456789") || trim(established.value)=="")
		{
			$("#established_text").hide().html("Please enter establishment year.").css("color","red").fadeIn();
			flag=0;
		}
		else
		{
			$("#established_text").hide();
			flag++;
		}
		if(pv_style.selectedIndex==0)
		{
			$("#pv_style_text").hide().html("Please select management style.").css("color","red").fadeIn();
			flag=0;
		}
		else
		{
			$("#pv_style_text").hide();
			flag++;
		}
		/*if(document.getElementById('eligibility').selectedIndex==-1)
		{
			$("#criteria_text").hide().html("Please select eligibility.").css("color","red").fadeIn();
			flag=0;
		}
		else
		{
			$("#pv_style_text").hide();
			flag++;
		}*/
		if(trim(fees.value)=="")
		{
			$("#fees_text").hide().html("Please enter fees.").css("color","red").fadeIn();
			flag=0;
		}
		else
		{
			$("#fees_text").hide();
			flag++;
		}
		/*if(trim(admission_procedure.value)=="")
		{
			$("#admission_procedure_text").hide().html("Please enter admission procedure.").css("color","red").fadeIn();
			flag=0;
		}
		else
		{
			$("#admission_procedure_text").hide();
			flag++;
		}*/
		/*if(examination_system.selectedIndex==0)
		{
			$("#examination_system_text").hide().html("Please select system of examination.").css("color","red").fadeIn();
			flag=0;
		}
		else
		{
			$("#examination_system_text").hide();
			flag++;
		}*/
		if(trim(description.value)=="")
		{
			$("#description_text").hide().html("Please enter description.").css("color","red").fadeIn();
			flag=0;
		}
		else
		{
			$("#description_text").hide();
			flag++;
		}
		if(trim(strength.value)=="")
		{
			$("#strength_text").hide().html("Please enter faculty strength.").css("color","red").fadeIn();
			flag=0;
		}
		else
		{
			$("#strength_text").hide();
			flag++;
		}
		//alert(flag);return false;
		if(flag==18)	
			document.institute_frm.submit();
		else
			return false;
	}
}
function checkInstituteStepOne()
{
	with(document.institute_frm)
	{
		var flag=0;
		if(trim(institute_name.value)=="")
		{
			$("#institute_name_text1").hide().html("Please enter institute name.").css("color","red").fadeIn();
			flag=0;
		}
		else
		{
			$("#institute_name_text1").hide();
			flag++;
		}
		if(trim(contact_name.value)=="")
		{
			$("#contact_name_text").hide().html("Please enter contact name.").css("color","red").fadeIn();
			flag=0;
		}
		else
		{
			$("#contact_name_text").hide();
			flag++;
		}
		if(!isValidMail(email.value))
		{
			$("#email_text").hide().html("Please enter a valid email address.").css("color","red").fadeIn();
			flag=0;
		}
		else
		{
			$("#email_text").hide();
			flag++;
		}
		if(password.value=="")
		{
			$("#password_text").hide().html("Please enter your password.").css("color","red").fadeIn();
			flag=0;
		}
		else
		{
			$("#password_text").hide();
			flag++;
		}
		if(confirm_password.value=="")
		{
			$("#confirm_password_text").hide().html("Please confirm your password.").css("color","red").fadeIn();
			flag=0;
		}
		else
		{
			$("#confirm_password_text").hide();
			flag++;
		}
		if(confirm_password.value!=password.value)
		{
			$("#confirm_password_text").hide().html("Your passwords do not match.").css("color","red").fadeIn();
			flag=0;
		}
		else
		{
			$("#confirm_password_text").hide();
			flag++;
		}		
		if(flag==6){	
			if(agree.checked==false){
				$("#agree_msg").hide().html("Please read and accept the Terms and Conditions to register.").css("color","red").fadeIn();
				return false;
			}
			else
				document.institute_frm.submit();
				return true;
		}
		else
			return false;
	}
}

var count_awards=1;
function addAwards(action,id)
{
	if(action=='add')
	{
		var next_awards=count_awards+1;
		var previous_awards=count_awards;
		$("#"+count_awards).after('<li class="clearLeft" id="'+next_awards+'"><div class="floatLeft" style="padding-left:200px;"><input type="text" name="awards[]" id="awards[]" maxlength="100" size="41"/>&nbsp;&nbsp;<a href="javascript:void(0)" style="text-decoration:none;color:red;" onclick="addAwards(\'remove\','+next_awards+')">X</a>&nbsp<a href="javascript:void(0)" onclick="addAwards(\'add\','+next_awards+')" id="add" style="font-size:12px; vertical-align:middle;">Add More</a> </div></li>');
		$("#"+next_awards).fadeIn('slow');
		$("#"+previous_awards+" a").html('');
		
		if(next_awards==10)
			$("#add").html('');	
		count_awards++;
	}
	else if(action=='remove')
	{		
		$("#"+id).remove();
		var previous_awards=id-1;
		if(id!=2)
			$("#"+previous_awards+" a").html('X');	
		$("#add").html('Add More');	
		count_awards--;
	}
}
function isAlphabet(str)
{
	var rule=/^[A-Za-z]$/;
	if(rule.test(str))
		return true;
	else
		return false;
}
function addToShortList(institute_id)
{	

	$.ajax({type: "GET",url: full_path+"/ajax.php",data: "action=addtoshortlist&institute_id="+institute_id,async: false,
		success:function(response)
		{	
			if(response.search('Already Shortlisted')!=-1)				
				alert("Already added in your shortlist.");				
			else if(response.search('added')!=-1){
				alert("Successfully added in your shortlist.");
				$("#add_to_shrtlst_anchor"+institute_id).remove();
				$("#add_to_shrtlst_span"+institute_id).show().html("Added to Shortlist");
			}				
			else if(response.search('Login')!=-1)	
				window.location.href=full_path+'/student-login.php';
			
		}
	  });
}

function addToShortList2(institute_id,course_type)
{	

	$.ajax({type: "GET",url: full_path+"/ajax.php",data: "action=addtoshortlist2&institute_id="+institute_id+"&course_type="+course_type,async: false,
		success:function(response)
		{	
			if(response.search('Already Shortlisted')!=-1){				
				alert("Already added in your shortlist.");	
			}else if(response.search('max_limit')!=-1){
				alert("Oops! You can shortlist upto 50 colleges only.");	
			}
			else if(response.search('added')!=-1){
				alert("Successfully added in your shortlist.");
				$("#add_to_shrtlst_anchor"+institute_id).remove();
				$("#add_to_shrtlst_span"+institute_id).show().html("Added to Shortlist");
			}				
			
			
		}
	  });
}

function sendRequest(institute_id)
{
	
	$.ajax({type: "GET",url: full_path+"/ajax.php",data: "action=sendrequest&institute_id="+institute_id,async: false,
		success:function(response)
		{ 
			if(response.search('Already Sent')!=-1)			
				alert("Already sent.");
			if(response.search('Sent')!=-1)
				alert("Your request has been sent.");
			else if(response.search('Login')!=-1)	
				window.location.href=full_path+'/student-login.php?ref='+institute_id;
		}
	  });
}
function checkAll(t,name)
{
	var controls=document.getElementsByName(name);	
	if(t.checked)
	{
		for(var i=0;i<controls.length;i++)
		{
			controls[i].checked=true;
		}
	}
	else
	{
		for(var i=0;i<controls.length;i++)
		{
			controls[i].checked=false;
		}
	}
}

function StudentreadMessage(action)
{
	
	var response=document.getElementsByName('response[]');	
	var selected=0;
	for(var i=0;i<response.length;i++)
	{
		if(response[i].checked)
			selected++;
	}
	if(response.length==0)
	{
		alert("You do not have any response.");
	}
	else if(selected==0)
	{
		alert("Please select response.");
	}
	else
	{
		$.ajax({type: "GET",url: full_path+"/ajax.php",data: $("#msg_frm").serialize()+"&action="+action,async: false,
			success:function(reply)
			{ 
				if(reply.search('unread_request')!=-1)	
				{
					for(var i=0;i<response.length;i++)
					{
						if(response[i].checked){						
												
							$("#div_response_"+response[i].value).removeClass('read_mail');}
					}
				}
				else if(reply.search('read_request')!=-1)	
				{
					for(var i=0;i<response.length;i++)
					{
						if(response[i].checked){
												
							$("#div_response_"+response[i].value).addClass('read_mail');
						}
					}
				}
				
			}
		  });
	}
}
function readMessage(action)
{
	var response=document.getElementsByName('response[]');	
	var selected=0;
	for(var i=0;i<response.length;i++)
	{
		if(response[i].checked)
			selected++;
	}
	if(response.length==0)
	{
		alert("You do not have any response.");
	}
	else if(selected==0)
	{
		alert("Please select response.");
	}
	else
	{
		$.ajax({type: "GET",url: full_path+"/ajax.php",data: $("#msg_frm").serialize()+"&action="+action,async: false,
			success:function(reply)
			{ 
				if(reply.search('read_request')!=-1)	
				{
					for(var i=0;i<response.length;i++)
					{
						if(response[i].checked)						
							$("#response"+response[i].value).css("font-weight","normal");
					}
				}
				else if(reply.search('unread_request')!=-1)	
				{
					for(var i=0;i<response.length;i++)
					{
						if(response[i].checked)						
							$("#response"+response[i].value).css("font-weight","bold");
					}
				}
				
			}
		  });
	}
}
function checkRequest(action)
{
	var email_list='';
	var request=document.getElementsByName('request[]');	
	var selected=0;
	for(var i=0;i<request.length;i++)
	{
		if(request[i].checked){
			selected++;			
		}
	}
	
	if(request.length==0)
	{
		alert("You do not have any request.");
	}
	else if(selected==0)
	{
		alert("Please select request.");
		
	}
	
	for(var i=0;i<request.length;i++)
	{
		if(request[i].checked){
			selected++;
			if(action=='send_bulk_response'){
				email_list=email_list+request[i].value+',';	
				document.getElementById('email_ids').value=email_list;				
			}	
		}
	}
	if(action=='delete_request'){	
		
		var r=confirm("Are you sure you want you want to delete this request?");
		if (r==false)
		  {
		 	exit();
		  }
		
	}
	
	if(selected!=0)
	{
		$.ajax({type: "GET",url: full_path+"/ajax.php",data: $("#msg_frm").serialize()+"&action="+action,async: false,
			success:function(reply)
			{ 
				
		if(reply.search('unread_request')!=-1)	
		{
			for(var i=0;i<request.length;i++)
			{
				if(request[i].checked){						
					$("#request"+request[i].value).css("font-weight","bold");
				 $("#app_request"+request[i].value).css("font-weight","bold");
				}
			}
		}
		else if(reply.search('read_request')!=-1)	
		{
			for(var i=0;i<request.length;i++)
			{
				if(request[i].checked){	
								
					$("#request"+request[i].value).css("font-weight","normal");
					$("#app_request"+request[i].value).css("font-weight","normal");
					
				}
			}
		}
		else if(reply.search('deleted_request')!=-1)	
		{
			for(var i=0;i<request.length;i++)
			{
				if(request[i].checked){
					$("#req"+request[i].value).hide();							
				}
					
			}
			window.location.href=full_path+'/college-requests.php';
		}
				
				
				
			}
		  });
	}
}
function increaseClicks(institute_id,course_type,place_of_click){
	$.ajax({type: "GET",url: full_path+"/ajax.php",data: "institute_id="+institute_id+"&course_type="+course_type+"&place_of_click="+place_of_click+"&action=clicks",async: false});
}
function increaseClicks2(institute_id,course_type,place_of_click,full_path){
	$.ajax({type: "GET",url: full_path+"/increaseClicks",data: "institute_id="+institute_id+"&course_type="+course_type+"&place_of_click="+place_of_click+"&action=clicks",async: false});
}


function save_logo(){	
		if(document.getElementById('userfile').value==""){
			alert('Please upload an image');
			return false;
		}else{		
			document.getElementById('logo_form').submit();			
			return true;
		}
}
function save_image(){	

	with(document.image_form){
		if(title.value==""){
			alert('Please enter title');
			return false;
		}else{		
			document.image_form.submit();			
			return true;
		}
	}
}

function checkVideo(){
			
			document.getElementById('video_form').submit();			
			return true;
		
}

		
function checkOverview(){
		with(document.overview_frm){
				var err=0;
				
				
				if(college_email.value==''){	
					document.getElementById('college_email_text').style.visibility='visible';	
					
					$('#college_email').addClass('error');
					err++;
				}else{
					$('#college_email_text').hide();					
				}
				if(established.value==""){	
					document.getElementById('established_text').style.visibility='visible';	
					$('html, body').animate({ scrollTop: $("#established").offset().top }, 500);					
					$('#established').addClass('error');
					err++;
				}else{
					$('#established_text').hide();					
				}
				if(pv_style.value==""){	
					document.getElementById('pv_style_text').style.visibility='visible';			
					
					$('#pv_style').addClass('error');
					err++;
				}else{
					$('#pv_style_text').hide();					
				}
				if(state.value==""){	
					document.getElementById('state_text').style.visibility='visible';		
				
					$('#state').addClass('error');
										
					err++;
				}else{
					$('#state_text').hide();					
				}
				if(err==0){
					document.overview_frm.submit();
					return true;
				}else
					return false;					
		}
}
function checkFaculty(){
	with(document.faculty_frm){		  
			  document.faculty_frm.submit();
			  return true;
		  
	}
}

function checkInfrastructure(){
	with(document.infrastructure_frm){
		  var err=0;				
		 
		  if(err==0){
			  document.infrastructure_frm.submit();
			  return true;
		  }else{
			  return false;
		  }
	}
}		
function checkAccountSettings(){
	with(document.account_settings_frm){
		  var err=0;				
		  if(new_password.value!="" && password.value==''){			
				document.getElementById('new_password_text').style.display='block';
				
			  err++;
		  }else{
			  $('#new_password_text').hide();					
		  }
		  if(new_password.value!="" && re_new_password.value!='' && (new_password.value!=re_new_password.value)){
			 document.getElementById('wrong_password_text').style.display='block';
			  err++;
		  }else{
			  $('#wrong_password_text').hide();					
		  }
		  if(err==0){
			  document.account_settings_frm.submit();
			  return true;
		  }else{
			  return false;
		  }
	}
}	

function checkEvents(){
	with(document.event_frm){
		  var err=0;	
		 	
		  if(name.value=="" ){			 
			 
			document.getElementById('name_text').style.visibility='visible';
			  $('#name').addClass('error');	
			  err++;
		  }else{
			  $('#name_text').hide();
			   $('#name').removeClass('error');					
		  }
		  if(date.value=="" ){			 
			 
			document.getElementById('date_text').style.visibility='visible';
			  $('#date').addClass('error');	
			  err++;
		  }else{
			  $('#date_text').hide();
			   $('#date').removeClass('error');					
		  }
		  if(end_date.value=="" ){			 
			 
			document.getElementById('end_date_text').style.visibility='visible';
			  $('#end_date').addClass('error');	
			  err++;
		  }else{
			  $('#end_date_text').hide();
			   $('#end_date').removeClass('error');					
		  }
		  if(err==0){
			  document.event_frm.submit();
			  return true;
		  }else{
			  return false;
		  }			  
	}
}
function checkAwards(){
	with(document.award_frm){
		  var err=0;	
		 	
		  if(name.value=="" ){
			  document.getElementById('name_text').style.visibility='visible';
			  $('#name').addClass('error');	
			  err++;
		  }else{
			  $('#name_text').hide();					
		  }
		  if(err==0){
			  document.award_frm.submit();
			  return true;
		  }else{
			  return false;
		  }			  
	}
}
function checkAlumini(){
	with(document.alumini_frm){
		  var err=0;	
		 	
		  if(name.value=="" ){
			  document.getElementById('name_text').style.visibility='visible';			
			  $('#name').addClass('error');	
			  err++;
		  }else{
			  $('#name_text').hide();					
		  }
		  if(err==0){
			  document.alumini_frm.submit();
			  return true;
		  }else{
			  return false;
		  }			  
	}
}
function checkCollaboration(){
	with(document.coll_frm){
		  var err=0;	
		 	
		  if(name.value=="" ){
			  document.getElementById('name_text').style.visibility='visible';			
			  $('#name').addClass('error');	
			  err++;
		  }else{
			  $('#name_text').hide();					
		  }
		  if(err==0){
			  document.coll_frm.submit();
			  return true;
		  }else{
			  return false;
		  }			  
	}
}
function checkDocument(){
	
	with(document.document_frm){
		  var err=0;	
		 	
		  if(title.value=="" ){
			 
			  $("#title_text").show().css("visibility","visible");			 		
			  $('#title').addClass('error');	
			  err++;
		  }else{
			  $('#title_text').hide();	
			  $('#title').removeClass('error');					
		  }
		  
		  if(document.value=="" && document.mode=='add'){
			 $("#document_text").show().css("visibility","visible");
			 $('#document').addClass('error');
			   err++;
			  
		   }else{
			  $('#document_text').hide();
			  $('#document').removeClass('error');					
		  }
		  if(err==0){
			  document.document_frm.submit();
			  return true;
		  }else{
			  return false;
		  }			  
	}
}

function toggle_display(x, div_name){	
		
		if(x=='yes'){
			document.getElementById(div_name).style.display='block';	
		}else{
			document.getElementById(div_name).style.display='none';	
		}
}


function checkCourse(){
	with(document.course_frm){
		  var err=0;		 	
		  if(course_type.value=="" ){
			  alert('Please select a course');
			  err++;
		  }
		 else if(fees.value=="" ){
			  alert('Please enter tution fees');
			  err++;
		  }
		 else  if(show_seats_no.checked==true ){
				 if(total_seats.value==''){
					  alert('Please enter total seats');
					  err++;
				}
		  }
		 else  if(show_seats_yes.checked==true ){
			 var check_seats=0;
			var seats_input=document.getElementsByName("seats[]");
			for(var i=0;i<seats_input.length;i++){
				if(seats_input[i].value!=''){
					check_seats++;
				}				
			}//end for
			if(check_seats==0){
				alert('Please select atleast one branch');
				err++;	
			}
	
			
		 }
		  if(err==0){
			  document.course_frm.submit();
			  return true;
		  }else{
			  return false;
		  }			  
	}
}

function cancel_page(page){	
	window.location.href=full_path+'/'+page;
}

function showColleges(text)
{	
	if(text!=''){
	$("#livesearch_inner_div_ul").html='';
	document.getElementById('hidden_institute_id').value='';
	$.ajax({type: "GET",url: full_path+"/ajax.php",data: "action=showColleges&text="+text,async: false,
		success:function(response)
		{	
			if(response.search('Result not found')!=-1)				
				//$("#livesearch_inner_div_ul").show().html(response);	
				$("#livesearch").hide();			
			else 
				
				$("#livesearch").show();
				$("#livesearch_inner_div_ul").show().html(response);
				
			
		}
	  });
	  
	}else{
		$("#livesearch").hide();
	}
}
function select_college(institute_id){
	
	$.ajax({type: "GET",url: full_path+"/ajax.php",data: "action=select_college&institute_id="+institute_id,async: false,
		success:function(response){						
			document.getElementById('keyword_text').value=response;
			document.getElementById('hidden_institute_id').value=institute_id;	
			$("#livesearch").hide();	
			go_to_profile();	
		}
	  });
	
}

function select_college_by_name(v){	
	
			document.getElementById('hidden_institute_id').value=v;	
			var name=v;
			name=name.replace(/^\s+|\s+$/g, '').replace(/\,/g,' ').replace(/\s+/g,'_');
			proxy='/colleges/'+name;
			window.location.href=proxy;	
			return false;	
	
}

/*function select_college_by_name(v){	
		
	alert(full_path+"/ajax.php?action=select_college_by_name&institute_name="+v);	
	$.ajax({type: "GET",url: full_path+"/ajax.php",data: "action=select_college_by_name&institute_name="+v,async: false,
		success:function(response){						
			alert(response);
			document.getElementById('hidden_institute_id').value=response;				
			var name=response;
			
			name=name.replace(/^\s+|\s+$/g, '').replace(/\,/g,' ').replace(/\s+/g,'_');
			proxy=full_path+'/colleges/'+name;
			//window.location.href=proxy;	
			//return false;	
		}
	  });
}
*/
function go_to_profile2(){ 
	var proxy = '/search-result.php';
	var frm=document.getElementById('keyword_search_form');		
	var name=document.getElementById('CityAjax').value;
	if(document.getElementById('hidden_institute_id').value!=''){	
		name=name.replace(/^\s+|\s+$/g, '').replace(/\,/g,' ').replace(/\s+/g,'_').replace(/\&/g,'&amp;');
		proxy='/colleges/'+name;	
		window.location.href=proxy;	
		return false;	
	}else{
		name=encodeURI(name);
		if(name!='' && name!='Enter%20College%20Name...' && name!='Enter%2520College%2520Name...'){			
			proxy='/search-result.php?'+'keyword='+name;	
			window.location.href=proxy;	
			return false;
		}else{
			//alert('Please enter college name');
			return false;
		}
	}	
	
}

function showColleges_profile(text)
{	
	if(text!=''){
	document.getElementById('hidden_institute_id').value='';
	$.ajax({type: "GET",url: "/ajax.php",data: "action=showColleges_profile&text="+text,async: false,
		success:function(response)
		{	
			if(response.search('Result not found')!=-1)				
				//$("#quckSer").show().html(response);
				$("#quckSer").hide();				
			else 
				
				$("#quckSer").show();
				$("#quckSer_ul").show().html(response);
				
			
		}
	  });
	  
	}else{
		$("#quckSer").hide();
	}
}

function select_college_profile(institute_id){
	
	$.ajax({type: "GET",url: "/ajax.php",data: "action=select_college_profile&institute_id="+institute_id,async: false,
		success:function(response){						
			document.getElementById('keyword_text').value=response;
			document.getElementById('hidden_institute_id').value=institute_id;	
			$("#quckSer").hide();	
			go_to_profile();	
		}
	  });
	
}


function go_to_profile(){ 
	var proxy = '/search-result.php';
	var frm=document.getElementById('keyword_search_form');	
	var hidden_institute_id=document.getElementById('hidden_institute_id').value;	
	proxy = 'institute-profile.php?id='+hidden_institute_id;
	var name=document.getElementById('keyword_text').value;
	if(hidden_institute_id!=''){	
		name=name.replace(/^\s+|\s+$/g, '').replace(/\,/g,' ').replace(/\s+/g,'_').replace(/\&/g,'&amp;');
		proxy='/colleges/'+name;		
	}else{
		proxy='/search-result.php?'+'keyword='+name;	
	}
	
	//frm.action=proxy;
	//frm.submit();
	window.location.href=proxy;	
	return false;

	//window.open(proxy);
	//$.ajax({type: "GET",url: proxy});	
	//return true;
}


function getcourse(course_id){
	$.ajax({type: "GET",url: full_path+"/ajax.php",data: "action=getcourse_for_profile&course_id="+course_id,async: false,
		success:function(response){	
			if(response.search('Course not found')!=-1)	{
				alert('Course not found');
			}else{
				window.location.reload();
			}
		}
	});
	
}


/*function facebook_login_ics(){
	$.ajax({type: "GET",url: full_path+"/ajax.php",data: "action=facebook_login_ics",async: false,
		success:function(response){	
			if(response.search('Facebook Login Done')!=-1)	{
				window.location.reload();
			}
		}
	});
}*/
function facebook_login_ics(){
	$.ajax({type: "GET",url: full_path+"/ajax.php",data: "action=facebook_login_ics",async: false,
		success:function(response){	
			if(response.search('Facebook Login Done')!=-1)	{				
					
					if(document.getElementById('is_send_profile').value==1){
					window.location.reload();	
				window.open(full_path+'/send-profile.php?institute_id='+document.getElementById('login_institute_id').value+'&course_type='+document.getElementById('login_course_type').value);
				
					
					}else if(document.getElementById('is_shortlist').value==1){
						window.location.reload();
					addToShortList2(document.getElementById('login_institute_id').value,document.getElementById('login_course_type').value);
				
					}else{								
						window.location.reload();
					}
			}
		}
	});
}





function checkStudentAccountSettings()
{
	with(document.student_account_settings_frm)
	{
		var flag=0;
		
		if(trim(name_of_student.value)=="")
		{
			document.getElementById('name_of_student_text').style.display='block';
			flag++;
		}
		else
		{
			$("#name_of_student_text").hide();
			
		}
		
		if(!isValidMail(email_of_student.value))
		{
			$("#email_of_student_text").show();
			flag++;
		}
		else
		{
			$("#email_of_student_text").hide();
			
		}
		
		if(flag==0){
			document.student_account_settings_frm.submit();
			return true;	
		}else{
			return false;
		}
	}
}

function checkSendProfile()
{
	with(document.send_profile_frm)
	{
		var flag=0;		
		if(trim(state.value)==""){			
			alert('Please enter state of residence');
			flag++;
		}else if(trim(mobile.value)==""){
			alert('Please enter your mobile number');
			flag++;
		
		}else if(trim(plan_to_take_admission.value)==""){
			alert('Please enter year of planned admission');
			flag++;
		}else if(d.value=="" || m.value=="" || y.value==""){
			alert('Please enter date of birth');
			flag++;
		}
		if(flag==0){
			document.send_profile_frm.submit();
			return true;	
		}else{
			return false;
		}
	}
}

function sendStudentPassword(){
	with(document.student_login_frm)
	{
		var flag=0;		
		var email=document.getElementById('student_email').value;	
		
		if(!isValidMail(student_email.value))
		{
			$("#student_email_text").show();
			flag++;
		}
		else
		{
			$("#student_email_text").hide();
			
		}
		if(flag==0){
			var main_url=full_path+"/ajax.php?action=sendspassword&email="+email;
			
				$.ajax({type: "GET",url: main_url,async: false,
			success:function(response){	
				if(response.search('yes')!=-1)	{
					alert('Password Sent');
										
				}else {
					alert('Email Address does not exist');
				}
				
				
			}
		});
			
		}
		
	}
	
}

function send_profile_signin(institute_id,course_type){
	  
	 //institute id
	  document.student_login_frm.login_institute_id.value=institute_id;
		document.student_registration_frm.login_institute_id.value=institute_id;
	  
	   //course_type
	   document.student_login_frm.login_course_type.value=course_type;
		document.student_registration_frm.login_course_type.value=course_type;	
		//is_shortlist
		document.student_login_frm.is_send_profile.value=1;
		document.student_registration_frm.is_send_profile.value=1;
	   return true;
   }
 function add_toshortlist_signin(institute_id,course_type){	
		//institute id
		document.student_login_frm.login_institute_id.value=institute_id;
		document.student_registration_frm.login_institute_id.value=institute_id;
		//course_type
		document.student_login_frm.login_course_type.value=course_type;
		document.student_registration_frm.login_course_type.value=course_type;
		//is_shortlist
		document.student_login_frm.is_shortlist.value=1;
		document.student_registration_frm.is_shortlist.value=1;				
	   return true;
	   
   }
 function checkCompareCollege(){
	 
	 var err=0;
		var checkboxes=document.getElementsByName("compare[]");
		for(var i=0;i<checkboxes.length;i++){
				if(checkboxes[i].checked==false){
					err=1;					
					//to check the particular row
				}else{
					err=0;					
					exit;
				}
		}
		
	
	if(err>0){
		alert('Please check atleast one college to compare');
		return false;	
	}else{
		return true;	
	}
 }
 
 
 //Student Forgot Password Box
 function checkStudentForgotPassword(){
	 with(document.student_forgot_password_frm)
	{
		var flag=0;		
		var email=document.getElementById('student_forgot_email').value;	
		
		if(!isValidMail(email))
		{
			$("#student_forgot_email_text").show();
			$("#student_forgot_email").focus();
			flag++;
		}else{
			$("#student_forgot_email_text").hide();
			
		}
		if(flag==0){
			var main_url=full_path+"/ajax.php?action=sendspassword&email="+email;
			
				$.ajax({type: "GET",url: main_url,async: false,
			success:function(response){	
				if(response.search('yes')!=-1)	{
					alert('Password Sent! Please check your mailbox!');
										
				}else {
					alert('Email Address does not exist');
				}
				
				
			}
		});
			
		}else{
			return false;	
		}
		
	}
 }
 
 
 ///Student Registration box
function chkStudent_Registration()
{
	with(document.student_registration_frm)
	{
		var flag=0;
		
		if(trim(student_registration_name.value)=="")
		{
			$("#student_registration_name_text").show();
			flag++;
		}else{
			$("#student_registration_name_text").hide();			
		}		
		if(!isValidMail(student_registration_email.value))
		{
			$("#student_registration_email_text").show();
			flag++;
		}else{
			$("#student_registration_email_text").hide();
			
		}
		if(student_registration_password.value=="")
		{
			$("#student_registration_password_text").show();
			flag++;
		}else{
			$("#student_registration_password_text").hide();			
		}		
		if(agree.checked==false){
				$("#agree_msg").css('display','block');
				
				flag++;				
		}else{
			$("#agree_msg").hide();			
		}
		if(flag==0){			
			
			var main_url=full_path+"/ajax_student_registration.php?email="+document.getElementById('student_registration_email').value+"&password="+document.getElementById('student_registration_password').value+"&name="+document.getElementById('student_registration_name').value+"&captcha="+document.getElementById('captcha').value;	
			
				$.ajax({type: "GET",url: main_url,async: false,
			success:function(response){	
				if(response.search('Login Successful')!=-1)	{
					alert('Thankyou for registering with IndiaCollegeSearch!');
					if(document.student_registration_frm.is_send_profile.value==1){
						
				window.open(full_path+'/send-profile.php?institute_id='+document.getElementById('login_institute_id').value+'&course_type='+document.getElementById('login_course_type').value);
					
					}else if(document.student_registration_frm.is_shortlist.value==1){
					
					addToShortList2(student_registration_frm.login_institute_id.value,student_registration_frm.login_course_type.value);
					}
					//return true;
					
				}else if(response.search('invalid_code')!=-1){
					alert('Please enter a valid code.');
					flag++;
					return false;
				}else if(response.search('Duplicate exist')!=-1){
					alert('This email already exists.');
					document.getElementById('student_registration_email').value='';
					document.getElementById('student_registration_email').focus();
					flag++;
					return false;
				}
			}
			});
		
		}else{			
			return false;
		}
		
		if(flag>0){
			return false;
		}
	}
}


function chkSendQueryFrm(){
	
	with(document.SendQueryFrm)
	{
		var flag=0;
		
		if(trim(query_name.value)=="")
		{
			$("#query_name_text").html(" Please enter name");
			$("#query_name_text").show();
			flag++;
			return false;	
		}else{
			$("#query_name_text").html('');
		}
		if(!isValidMail(query_email.value))
		{
			$("#query_email_text").html(" Please enter a valid email address");
			$("#query_email_text").show();
			flag++;
			return false;	
		}else{
			$("#query_email_text").html('');
		}
		
		if(flag==0){
			
			var main_url=full_path+"/ajax.php?action=sendQuery&college_name="+document.getElementById('query_college').value+"&email="+document.getElementById('query_email').value+"&name="+document.getElementById('query_name').value;		
				$.ajax({type: "GET",url: main_url,async: false,
			success:function(response){	
				if(response.search('query_sent')!=-1)	{
					
					$("#success_query").html("Query submitted!");					
					$("#success_query").show();
															
				}else {
					alert('Query not submitted');
					flag++;
					
				}				
			}
		});
		
		return false;	
		}else{
			return false;	
		}
			
		
	}
}